package com.anuo.app.common.entity;

import com.anuo.app.common.globalhandle.AppException;
import com.sun.org.apache.regexp.internal.REUtil;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * 请求
 */
public class Request<T> {
    private String token;
    private List<T> entities;
    private String version;

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public List<T> getEntities() {
        return entities;
    }

    public void setEntities(List<T> entities) {
        this.entities = entities;
    }

//    public void setEntities(T entity) {
//        List<T> list = new ArrayList<>();
//        list.add(entity);
//        this.entities = list;
//    }


    public T getFirstEntity() {
        if (entities.size() > 0) {
            return getEntities().get(0);
        }
        else{
            throw new AppException("entities为空,请传值", "null");
        }
    }

}


